function create_virtual_switches (
	[int] $scenario,  #scenario 0..#s-1
	[int] $computer #ordinateur 0..#c-1
) { 
	$VMServer = $CONFIG_SERVERS[$computer]
	$sujet = $sujets[$scenario]
	
	foreach($vswitch in $sujet.virtual_networks) {
		
		write-host ($sujet.scenario_name+"_"+$vswitch.name) -foregroundcolor yellow
		#check switch type
		$ERROR = $FALSE
		switch($vswitch.type) {
			"private"  {}
			"internal" {}
			"external" { 
				write-host "External switch will not be created. It will be binded to '$DEFAULT_EXTERNAL_SWITCHNAME' " -foregroundcolor red
				$error = $TRUE
			}
			
			default {
				write-host ("ERROR: unknow switch type: "+$vswitch.type+". Please check config\sujets\"+($scenario+1)+".ps1. SWITCH CREATION SKIPPED. ") -foregroundcolor red
				$error = $TRUE;
			}
		}
		if(-NOT $ERROR) {
			$vmswitchname = ($sujet.scenario_name+"_"+$vswitch.name)
			if(get-VMSwitch -Server $VMServer -virtualswitchname $vmswitchname) {
				write-host "ERROR: $vmswitchname already exists. " -ForegroundColor red
			} else {
				$command = ('New-VM'+$vswitch.type+'Switch -Server $VMServer -virtualSwitchName $vmswitchname')
				invoke-Expression $command
			}
		}
	}
}

$actions.Insert($actions.Count,"create_virtual_switches");
set-variable LANG_ACTION__CREATE_VIRTUAL_SWITCHES "CREER les switches virtuels" -scope global
